VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsEnvase"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
 Option Explicit

      'Contenedor del pesaje actual.
Private loc_Codigo           As Integer
Private loc_Descripcion     As String
Private loc_Tara              As Single
Private loc_Filtro             As String

Public Event Seleccionado()
Public Event MultiEnvases(ByVal Uds As Integer)

Public Property Get Codigo() As Integer
    Codigo = loc_Codigo
End Property

Public Property Get Descripcion() As String
    Descripcion = loc_Descripcion
End Property

Public Property Get Filtro() As String
    Filtro = loc_Filtro
End Property

Public Property Get Tara() As Single
    Tara = loc_Tara
End Property

Public Property Let Codigo(ByVal vData As Integer)
    loc_Codigo = vData
    If loc_Codigo >= 0 Then
        cargaDatos loc_Codigo
        RaiseEvent Seleccionado
    End If
End Property

Public Property Let Descripcion(ByVal vData As String)
    loc_Descripcion = vData
End Property

Public Property Let Filtro(ByVal vData As String)
    loc_Filtro = vData
End Property

Public Property Let Tara(ByVal vData As Single)
    loc_Tara = vData
    If loc_Tara > 0 Then RaiseEvent Seleccionado
End Property

Public Property Let Uds(ByVal vData As Integer)
    If vData > 0 Then
        RaiseEvent MultiEnvases(vData)
    End If
End Property

Private Sub Class_Initialize()
    loc_Codigo = -1
    loc_Descripcion = vbNullString
    loc_Tara = -1
    loc_Filtro = "Codigo"
End Sub

Public Sub Clear()
    Class_Initialize
End Sub

Private Sub cargaDatos(ByRef Codigo As Integer)
Dim rs_Envase As ADODB.Recordset
Dim sqlStr As String
    Set rs_Envase = New ADODB.Recordset
    sqlStr = "SELECT * FROM Contenedores WHERE Codigo = " & Codigo
    With rs_Envase
        .Open sqlStr, Cn_Local, adOpenStatic, adLockReadOnly
        loc_Descripcion = .Fields("Descripcion")
        loc_Tara = .Fields("Peso")
        If .State = adStateOpen Then .Close
    End With
    Set rs_Envase = Nothing
End Sub

Public Function HayEnvaseAnterior(ByVal codProveedor As Integer, ByVal codArticulo As String) As Boolean
'Dim rs_SQLEnvase As ADODB.Recordset
'Dim sqlStr As String
'Dim result As Boolean
'    Set rs_SQLEnvase = New ADODB.Recordset
'    sqlStr = "SELECT     TOP 1 PesajesLineas.Contenedor, PesajesLineas.Tara " & _
'                "FROM         PesajesLineas INNER JOIN Pesajes ON PesajesLineas.Num = Pesajes.Num " & _
'                "WHERE     (Pesajes.Proveedor = " & codProveedor & ") AND (PesajesLineas.Cod_Articulo = '" & codArticulo & "') " & _
'                "ORDER BY Pesajes.Conformado DESC"
'    With rs_SQLEnvase
'        .Open sqlStr, Cn_SQLLocal, adOpenStatic, adLockReadOnly
'        If .RecordCount Then
'            loc_Codigo = .Fields("Contenedor")
'            cargaDatos loc_Codigo
'            loc_Tara = .Fields("Tara")
'            result = True
'        Else
'            result = False
'        End If
'        If .state = adStateOpen Then .Close
'    End With
'    Set rs_SQLEnvase = Nothing
'    HayEnvaseAnterior = result
End Function
